namespace MyWebApi.Controllers;

using Microsoft.AspNetCore.Mvc;
using MyWebApi.Domian;
using MyWebApi.Dto;
using MyWebApi.Repository;
[ApiController]
[Route("api/[controller]")]
public class Controllers : controllerBase
{
    private readonly IRepository<Students> _studentRep;
    public StudentsController(IRepository<Students> studentRep)
    {
        _studentRep = studentRep;
    }
    [HttpGet]
    // 使用IAtionResult可以自定义返回值
    public async Task<IActionResult> Get(){
        var list =await _studentRep.getAllAsync();
        return Ok(
            new {
                code=200,
                data=list,
                msg="查询成功";
            }
        )
    }
}
// 第一步先声明方法
// [HttpPost]
// pbulic async Task<IActionResult> post(StudentCreateDto studentCreateDto)
// {
//     var student= new Students()
//     {

//     }
// var obj =await _studentRep.CreateAsync(student)
// return OK{
//     new {
//         code=200,
//         data=list,
//         msg="新增成功"
//     }
// }
// }